package com.gitee.huanminabc.ddd;

import com.gitee.huanminabc.ddd.api.WorkFeignApi;
import com.gitee.huanminabc.ddd.converter.WorkEntityToDtoConverter;
import com.gitee.huanminabc.ddd.dto.WorkDto;
import com.gitee.huanminabc.ddd.entity.WorkEntity;
import com.gitee.huanminabc.ddd.query.WorkQuery;
import com.gitee.huanminabc.nullchain.common.NullResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author huanmin
 * @Date 2024/6/4 下午6:23
 */
@RestController
@RequestMapping(WorkFeignApi.PATH)
public class WorkProvideApi  implements WorkFeignApi {
    @Autowired
    private WorkService workService;
    @Autowired
    private WorkEntityToDtoConverter workEntityToDtoConverter;

    @Override
    public NullResult<WorkDto> getWork(WorkQuery query) {
        WorkEntity work = workService.getWork(query.getWorkId());
        WorkDto dto = workEntityToDtoConverter.toDTO(work);
        return NullResult.success(dto);
    }
}
